<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html" template="/WEB-INF/templates/default.xhtml"
>
   <ui:define name="content">
      <h1>Book a parking lot</h1>

      <p>You have successfully deployed a Java EE 6 web application on JBoss AS 7.</p>

      <h:form id="reg">
         <h2>Register (Bean Validation example)</h2>
         <p>Enforces annotation-based constraints defined on the model class.</p>
         <table>
            <tr>
               <th style="text-align: right;"><h:outputLabel for="name" value="Name:" /></th>
               <td><h:inputText id="name" value="#{newMember.name}" /> <h:message for="name" errorClass="invalid" /></td>
            </tr>
            <tr>
               <th style="text-align: right;"><h:outputLabel for="email" value="Email:" /></th>
               <td><h:inputText id="email" value="#{newMember.email}" /> <h:message for="email" errorClass="invalid" /></td>
            </tr>
            <tr>
               <th style="text-align: right;"><h:outputLabel for="phoneNumber" value="Phone #:" /></th>
               <td><h:inputText id="phoneNumber" value="#{newMember.phoneNumber}">

                  </h:inputText> <h:message for="phoneNumber" errorClass="invalid" /></td>
            </tr>

            <tr>
               <th style="text-align: right;"><h:outputLabel for="dateFrom" value="From: " /></th>
               <td><h:inputText id="dateFrom" value="#{newBooking.dateFrom}">
                     <f:convertDateTime pattern="d-M-yyyy" />
                  </h:inputText> <h:message for="dateFrom" errorClass="invalid" /></td>
            </tr>

            <tr>
               <th style="text-align: right;"><h:outputLabel for="dateTo" value="To: " /></th>
               <td><h:inputText id="dateTo" value="#{newBooking.dateTo}">
                     <f:convertDateTime pattern="d-M-yyyy" />
               </h:inputText> <h:message for=" dateTo" errorClass="invalid" /></td>
            </tr>

            <tr>
               <th style="text-align: right;"><h:outputLabel for="parkingLot" value="Parking lot: " /></th>
               <td><h:selectOneListbox id="parkingLot" value="#{newBooking.parkingLot}" converter="omnifaces.SelectItemsConverter">
                     <f:selectItems value="#{parkingLotList}" var="parkingLot" itemLabel="#{parkingLot.id}" itemValue="#{parkingLot}" />
                  </h:selectOneListbox> <h:message for="parkingLot" errorClass="invalid" /></td>
            </tr>
         </table>
         <p>
            <h:commandButton id="register" action="#{bookingController.register}" value="Continue" />
            <h:outputText value=" Registered!" rendered="#{facesContext.postback and empty facesContext.messageList}" style="color: green;" />
         </p>
      </h:form>
      <h2>Members</h2>
      <h:panelGroup rendered="#{empty members}">
         <em>No registered members.</em>
      </h:panelGroup>
      <h:dataTable var="_member" value="#{members}" rendered="#{not empty members}">
         <h:column>
            <f:facet name="header">Id</f:facet>
                #{_member.id}
            </h:column>
         <h:column>
            <f:facet name="header">Name</f:facet>
                #{_member.name}
            </h:column>
         <h:column>
            <f:facet name="header">Email</f:facet>
                #{_member.email}
            </h:column>
         <h:column>
            <f:facet name="header">Phone #</f:facet>
                #{_member.phoneNumber}
            </h:column>
         <h:column>
            <f:facet name="header">REST URL</f:facet>
            <a href="#{request.contextPath}/rest/members/#{_member.id}">/rest/members/#{_member.id}</a>
         </h:column>
         <f:facet name="footer">
                REST URL for all members: <a href="#{request.contextPath}/rest/members">/rest/members</a>
         </f:facet>
      </h:dataTable>
   </ui:define>
</ui:composition>
